package com.study.modules.rabbitmq.testSimple;

import com.study.config.RabbitmqConfig;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class SimpleMqSenderService {
    @Autowired
    private RabbitTemplate restTemplate;

    public void sendMsg(String msg) {
        if (StringUtils.isBlank(msg)) {
            msg = "hello，你好!";
        }
        // 发送消息
        restTemplate.convertAndSend(RabbitmqConfig.SIMPLE_FANOUT_EXCHANGE, RabbitmqConfig.SIMPLE_FANOUT_QUEUE, msg);
    }

    public static void main(String[] args)  {
        try {
            ProcessBuilder pb = new ProcessBuilder("E:\\software\\Notepad--\\Notepad--.exe");
            Process process = pb.start();
            int exitCode = process.waitFor();
            System.out.println(exitCode);
        } catch (InterruptedException | IOException e) {
            e.printStackTrace();
        }
    }
}
